/**
 * Created by JuntaoYi
 * Date 2020/3/31
 */
import { fromJS } from 'immutable'
import * as constants from './constants'

// 初始默认的state
const defaultState = fromJS({
    myData: 0,
    loginUser: null
})

const getData = (state,action) => {
    return state.set('myData',action.data);
}

const getLoginUser = (state,action) => {
    return state.set('loginUser',action.data);
}

export default (state = defaultState, action) => {
    switch(action.type) {
        case constants.SET_DATA:
            return getData(state,action);
        case constants.LOGIN_USER:
            return getLoginUser(state,action)
        default:
            return state
    }
}
